<?php

$templateData = array(
    'title'             => $this->title,
    'resourceUri'       => $this->resourceUri,
    'description'       => $this->description,
    'descriptionHelper' => $this->descriptionHelper,
    'options'           => $this->options
); 

if (isset($this->description['http://purl.org/dc/terms/creator'][0]['value'])) {
    $creator = $this->description['http://purl.org/dc/terms/creator'][0]['value'];
    $creatorInstance = new OntoWiki_Resource($creator, OntoWiki::getInstance()->selectedModel);
    $creatorDescription = $creatorInstance->getDescription();
    $creatorDescription = $creatorDescription[$creator];
    $creatorHelper = $creatorInstance->getDescriptionHelper();
    
    $title = $creatorInstance->getTitle();
    $affixes = array();
    if (isset($creatorDescription['http://lod2.eu/schema/partner'][0]['value'])) {
        $partner = $creatorDescription['http://lod2.eu/schema/partner'][0]['value'];
        $affixes[] = $creatorHelper->getTitle($partner);
    }
    
    if (isset($creatorDescription['http://xmlns.com/foaf/0.1/title'][0]['value'])) {
        $title = sprintf(
            '%s %s', 
            $creatorDescription['http://xmlns.com/foaf/0.1/title'][0]['value'], 
            $title);
    }
    
    if (isset($creatorDescription['http://lod2.eu/schema/nameAffix'][0]['value'])) {
        $affixes[] = $creatorDescription['http://lod2.eu/schema/nameAffix'][0]['value'];;
    }
    
    if (count($affixes) > 0) {
        $title .= sprintf(' (%s)', implode(', ', $affixes));
    }
}

?>
<div class="maincontent">
    <div class="section testimonial">
        <h3><?php echo $title ?></h3>
        <div class="section-content">
            <?php if (isset($creatorDescription['http://xmlns.com/foaf/0.1/depiction'][0]['value'])): ?>
                <img width="100" src="<?php echo $creatorDescription['http://xmlns.com/foaf/0.1/depiction'][0]['value'] ?>" title="depiction of <?php echo  $creatorInstance->getTitle(); ?>"/>
            <?php endif; ?>
            <?php echo $this->partial('lod2/content.phtml', $templateData); ?>
            <?php if (isset($this->description['http://purl.org/dc/terms/creator'][0]['value'])): ?><p>Author: <?php 
                echo $title ?></p><?php 
            endif; ?>
        </div>
    </div>
</div>
